package com.yuanthink.gwt.client.registry;

import java.util.HashMap;
import java.util.Map;

import com.extjs.gxt.ui.client.data.ModelData;
import com.extjs.gxt.ui.client.widget.LayoutContainer;

/**
 * 
 * @author 06peng
 *
 */
public class WindowRegistry {
	@SuppressWarnings("rawtypes")
	static Map registry = new HashMap();

    @SuppressWarnings("unchecked")
	public static void register(String name, IWindowFactory factory) {
        registry.put(name, factory);
    }

    public static LayoutContainer getWindow(String name, ModelData config) {
        IWindowFactory factory = (IWindowFactory) registry.get(name);
        if (factory == null) {
            return null;
        }
        return factory.createWindow(config);
    }

    public static IWindowFactory getWindow(String name) {
        IWindowFactory factory = (IWindowFactory) registry.get(name);
        return factory; 
    }
}
